package com.bwie.service.impl;

import com.bwie.config.SecurityUtils;
import com.bwie.dao.UserDao;
import com.bwie.entity.User;
import com.bwie.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    @Override
    public Integer login(User user) {
        User u =userDao.login(user);
        if (u!=null){
            if (u.getLoginPwd().equals(user.getLoginPwd())){
                return 1;
            }
        }
        return 0;
    }

    @Override
    public int insertUser(User user) {
        String s = SecurityUtils.encryptPassword(user.getLoginPwd());
        user.setLoginPwd(s);
        return userDao.insertUser(user);
    }
}
